﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="detailandmed_v5_dokument", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(DetailandmedV5Dokument))]
    public class DetailandmedV5DokumentSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IDetailandmedV5Dokument clazz;
        
        public DetailandmedV5DokumentSerializer(IDetailandmedV5Dokument clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Number!=null) {
                Writer.WriteStartElement("number");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Number))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EsitamiseKpv!=null) {
                Writer.WriteStartElement("esitamise_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.EsitamiseKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokLiik!=null) {
                Writer.WriteStartElement("dok_liik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokLiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokLiikTekstina!=null) {
                Writer.WriteStartElement("dok_liik_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokLiikTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Aasta!=null) {
                Writer.WriteStartElement("aasta");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Aasta))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.NotarId!=null) {
                Writer.WriteStartElement("notar_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NotarId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.NotarNr!=null) {
                Writer.WriteStartElement("notar_nr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.NotarNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Piirkond!=null) {
                Writer.WriteStartElement("piirkond");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Piirkond))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PiirkondTekstina!=null) {
                Writer.WriteStartElement("piirkond_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PiirkondTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Olek!=null) {
                Writer.WriteStartElement("olek");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Olek))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OlekTekstina!=null) {
                Writer.WriteStartElement("olek_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OlekTekstina))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="number") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_dokument>number");
                }
                clazz.Number = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("number")).Value;
            }
            if (Reader.LocalName=="esitamise_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_dokument>esitamise_kpv");
                }
                clazz.EsitamiseKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("esitamise_kpv")).Value;
            }
            if (Reader.LocalName=="dok_liik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_dokument>dok_liik");
                }
                clazz.DokLiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok_liik")).Value;
            }
            if (Reader.LocalName=="dok_liik_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_dokument>dok_liik_tekstina");
                }
                clazz.DokLiikTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok_liik_tekstina")).Value;
            }
            if (Reader.LocalName=="aasta") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_dokument>aasta");
                }
                clazz.Aasta = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aasta")).Value;
            }
            if (Reader.LocalName=="notar_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_dokument>notar_id");
                }
                clazz.NotarId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("notar_id")).Value;
            }
            if (Reader.LocalName=="notar_nr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_dokument>notar_nr");
                }
                clazz.NotarNr = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("notar_nr")).Value;
            }
            if (Reader.LocalName=="piirkond") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_dokument>piirkond");
                }
                clazz.Piirkond = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("piirkond")).Value;
            }
            if (Reader.LocalName=="piirkond_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_dokument>piirkond_tekstina");
                }
                clazz.PiirkondTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("piirkond_tekstina")).Value;
            }
            if (Reader.LocalName=="olek") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_dokument>olek");
                }
                clazz.Olek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("olek")).Value;
            }
            if (Reader.LocalName=="olek_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_dokument>olek_tekstina");
                }
                clazz.OlekTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("olek_tekstina")).Value;
            }
        }
    }
}
